//
//  CircleProgress.m
//  Prayer
//
//  Created by CPX on 2018/5/28.
//  Copyright © 2018年 CPX. All rights reserved.
//

#import "CircleProgress.h"
#import "YYCategories.h"

@implementation CircleProgress

- (void)drawRect:(CGRect)rect {
    CGFloat radius = self.bounds.size.width / 2;
    CGFloat lineWidth = 2;
    
    UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(radius, radius) radius:radius - lineWidth / 2 startAngle:- M_PI/2 endAngle:M_PI * 2 * self.progress-M_PI/2 clockwise:YES];
    [UIColorHex(#43C784) setStroke];
    path.lineWidth = lineWidth;
//    path.lineCapStyle = kCGLineCapRound;
    [path stroke];
}

- (void)setProgress:(CGFloat)progress {
    
    _progress = progress;
    self.backgroundColor = [UIColor clearColor];
    
    [self setNeedsDisplay];
}

@end
